<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>第12题</title>
    <script>
        var bottom = 0;
        var height = 0;
        function caculate(flag) {
            if (!bottom) {
                bottom = prompt(flag ? '请输入正确的半径' : '请输入圆锥的底面半径');
            }
            if (!/^[0-9.]*$/i.test(bottom)) {
                caculate(true);
                return;
            }
            if (!height) {
                height = prompt(flag ? '请输入正确的高' : '请输入圆锥的高');
            }
            if (!/^[0-9.]*$/i.test(height)) {
                caculate(true);
                return;
            }
            // 底面积
            let area = Math.pow(parseFloat(bottom) * Math.PI, 2);
            
            // 体积
            let volume = 1 / 3 * area * height;
            alert(`该圆锥的体积为${volume}`);
            bottom = 0;
            height = 0;
        }
    </script>
</head>
<body>
    <p>
        请点击输入按钮，输入圆锥底面半径和高 
        <input type="button" value="输入" onclick="caculate()"> 
    </p>
</body>
</html>